const ValidatorError = require('../../shared/errors/ValidatorError')

class MenuError extends ValidatorError {
  constructor(message, status = 400) {
    super(message)
    this.status = status
  }
}

class MenuCodeExistError extends MenuError {
  constructor(id, code) {
    super(`系统【${id}】下的，菜单编码${code}已存在`)
  }
}

class MenuNotFoundError extends MenuError {
  constructor(id) {
    super(`菜单【${id}】不存在`)
  }
}

class HasChildMenuError extends MenuError {
  constructor(name) {
    super(`菜单【${name}】尚有子菜单，请先移除子菜单`)
  }
}

module.exports = {
  MenuNotFoundError,
  MenuCodeExistError,
  HasChildMenuError,
  MenuError,
}
